package com.hbnu.system.controller;

import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.Work_Qualification;
import com.hbnu.system.service.IWorkQualificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/workqulification")
@Api(tags = "著作量化模块")
public class WorkQualificationController {
    @Autowired
    private IWorkQualificationService iWorkQualificationService;

    @ApiOperation("著作量化添加")
    @PostMapping("/addWorkQulification")
    public Rest<Boolean> addWorkQulification(@RequestBody Work_Qualification work_qualification){
        boolean add = iWorkQualificationService.addWork_Qualification(work_qualification);
        return add ? Rest.success() : Rest.failed();
    }

    @ApiOperation("著作量化删除")
    @GetMapping("/deleteWorkQulification")
    public Rest<Boolean> deleteWorkQulification(String ID){
        boolean delete = iWorkQualificationService.deleteWork_Qualification(ID);
        return delete ? Rest.success() : Rest.failed();
    }

    @ApiOperation("著作量化查看")
    @GetMapping("/getWorkQulification")
    public Rest<List<Work_Qualification>> getWorkQulification(String WorkID){
        List<Work_Qualification> work_qualifications = iWorkQualificationService.getOneWork_Qualification(WorkID);
        return Rest.success(work_qualifications);
    }

    @ApiOperation("校级管理员修改量化分数")
    @PostMapping("/upWorkScore")
    public Rest<Boolean> upWorkScore(@RequestBody Work_Qualification work_qualification){
        boolean update = iWorkQualificationService.upWorkScore(work_qualification);
        return update ? Rest.success() : Rest.failed();
    }

}
